package com.fancy.learncenter.ui.activity;

import android.content.ClipData;
import android.content.ClipDescription;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.fancy.learncenter.R;
import com.fancy.learncenter.ui.activity.base.BaseActivity;
import com.fancy.learncenter.utils.ToastUtil;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 扫描结果页面
 */
public class ScanResultActivity extends BaseActivity {

    @Bind(R.id.scan_result)
    TextView scanResultText;
    @Bind(R.id.copy_tv)
    TextView copyTv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_scan_result);
        ButterKnife.bind(this);
        initView();
        initToolbar("提示");
    }

    private void initView(){

        final String scanResult = getIntent().getStringExtra("scan_result");
        scanResultText.setText(scanResult);

        copyTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                ClipboardManager manager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
                ClipData clipData = ClipData.newPlainText("result", scanResult);
                manager.setPrimaryClip(clipData);
                ToastUtil.show("复制成功");
            }
        });
    }


}
